home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
cstdio.arc
/
SRC.ARC
/
DSMEM.C
< prev
next >
Wrap
C/C++ Source or Header
|
1985-05-17
|
1KB
|
68 lines
/* dsmem.c - display memory.
(C) Copyright 1983,1984, 1985 Gregory R. Mansfield - All Rights Reserved.
G. R. Mansfield. 83/11/24.
Ver 1.1-5517.
*/
#include <defstd.h>
/* local functions */
static void chw(), chb(), chd();
/* local data */
static char *sp;
dsmem(a, f, n) /* display memory block */
BYTE *a; /* start of data */
WORD f; /* display field address */
int n; /* number of bytes to display */
{
BYTE *p;
char s[90];
int i, j;
for (i = 0; i < n; i += 16) {
sp = s;
*sp++ = ' ';
chw(f);
*sp++ = ' ';
f += 16;
p = a;
for (j = 0; j < 16; j++) {
if ((j & 3) == 0)
*sp++ = ' ';
chb(*p++);
*sp++ = ' ';
}
*sp++ = ' ';
for (j = 0; j < 16; j++) {
*sp++ = ((*a < 0x20) || (*a >= 0x7F)) || (*a == '$') ? '.' : *a;
a++;
}
*sp++ = '\n';
*sp = 0;
wcs(s);
}
}
static void chw(w) /* convert hex word */
WORD w;
{
chb(w >> 8);
chb(w);
}
static void chb(b) /* convert hex byte */
BYTE b;
{
chd(b >> 4);
chd(b);
}
static void chd(n) /* convert hex digit to p advancing p */
BYTE n;
{
n &= 0xF;
*sp++ = (n >= 10) ? n + ('A' - 10) : n + '0';
}